#import <Foundation/Foundation.h>

#import "PIObject.h"


extern NSInteger compareNativeTasks(id value1, id value2, void* orders);
extern NSInteger compareNativeTaskTitles(id value1, id value2, void* context);


enum PIClassificationType {
    ContextClassificationInContext = 1,
    ContextClassificationNoContext = 2,
    ContextClassificationOutOfContext = 3
};

enum PIActionType {
    PIActionNone = 0,
    PIActionNext = 1,
    PIActionActive = 2,
    PIActionPlanning = 3,
    PIActionDelegated = 4,
    PIActionWaiting = 5,
    PIActionHold = 6,
    PIActionPostponed = 7,
    PIActionSomeday = 8,
    PIActionCancelled = 9,
    PIActionReference = 10
};

enum PIImportanceType {
    PIImportanceNone = 0,
    PIImportanceTop = 1,
    PIImportanceHigh = 5,
    PIImportanceNormal = 10,
    PIImportanceLow = 15
};



@interface PITask : PIObject
{
    NSDate* dueDate;
    NSTimeZone* dueDateTimeZone;
    NSTimeInterval dueDateRaw;
    BOOL allDay;
    BOOL hasStartTime;
    
    NSDate* completionDate;

    PIClassificationType contextClassification;
    
    BOOL flagged;
    BOOL parent;
    BOOL child;
    
    NSString* parentKey;
    
    PIImportanceType importance;
    NSString* priority;
    PIActionType action;

    NSString* project;
}

@property (readonly) BOOL hasStartTime;

@property (retain) NSDate* dueDate;
@property (retain) NSTimeZone* dueDateTimeZone;
@property (readonly) NSTimeInterval dueDateRaw;
@property (retain) NSDate* completionDate;

@property (assign, getter=isAllDay) BOOL allDay;
@property (assign) PIClassificationType contextClassification;

@property (assign) PIImportanceType importance;
@property (retain) NSString* priority;
@property (assign) PIActionType action;

@property (retain) NSString* project;

@property (assign, getter=isFlagged) BOOL flagged;
@property (assign, getter=isParent) BOOL parent;
@property (assign, getter=isChild) BOOL child;

@property (retain) NSString* parentKey;

@property (assign) NSInteger percentComplete;
@property (retain) NSString* context;


+ (PITask*)nativeTaskWithKey:(NSString*)newKey version:(NSInteger)version title:(NSString*)newTitle icon:(NSString*)newIcon startDate:(NSDate*)newStart startDateTimeZone:(NSTimeZone*)newStartTimeZone startDateRaw:(NSTimeInterval)newStartDateRaw dueDate:(NSDate*)newEnd dueDateTimeZone:(NSTimeZone*)newEndTimeZone dueDateRaw:(NSTimeInterval)newEndRaw allDay:(BOOL)newAllDay calendar:(NSString*)newCalendar calendarIcon:(NSString*)newCalIcon calendarColor:(UIColor*)newCalColor parentKey:(NSString*)newParent;
+ (PITask*)piTaskWithKey:(NSString*)newKey version:(NSInteger)version title:(NSString*)newTitle icon:(NSString*)newIcon startDate:(NSDate*)newStart startDateTimeZone:(NSTimeZone*)newStartTimeZone startDateRaw:(NSTimeInterval)newStartDateRaw hasStartTime:(BOOL)newHasStartTime dueDate:(NSDate*)newEnd dueDateTimeZone:(NSTimeZone*)newEndTimeZone dueDateRaw:(NSTimeInterval)newEndRaw allDay:(BOOL)newAllDay calendar:(NSString*)newCalendar calendarIcon:(NSString*)newCalIcon calendarColor:(UIColor*)newCalColor parentKey:(NSString*)newParent;

- (BOOL)hasDetails;
- (BOOL)isInProgress;
- (BOOL)isComplete;

- (NSString*)shortDescription;

@end
